using System;
using System.Text;

namespace RealState.BusinessObjects
{
    [Serializable()]
    public class News
    {
        private int _RowNum;

        public int RowNum
        {
            get { return _RowNum; }
            set { _RowNum = value; }
        }

        private int _Id;

        public int Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        private string _Title;

        public string Title
        {
            get { return _Title; }
            set { _Title = value; }
        }

        private string _Content;

        public string Content
        {
            get { return _Content; }
            set { _Content = value; }
        }

        private string _Description;

        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }

        private Nullable<int> _CategoryId;

        public Nullable<int> CategoryId
        {
            get { return _CategoryId; }
            set { _CategoryId = value; }
        }

        private Nullable<int> _UserId;

        public Nullable<int> UserId
        {
            get { return _UserId; }
            set { _UserId = value; }
        }

        private Nullable<DateTime> _CreatedTime;

        public Nullable<DateTime> CreatedTime
        {
            get { return _CreatedTime; }
            set { _CreatedTime = value; }
        }

        private Nullable<bool> _IsActive;

        public Nullable<bool> IsActive
        {
            get { return _IsActive; }
            set { _IsActive = value; }
        }

        private Nullable<bool> _IsRemove;

        public Nullable<bool> IsRemove
        {
            get { return _IsRemove; }
            set { _IsRemove = value; }
        }

        private string _ImgPath;

        public string ImgPath
        {
            get { return _ImgPath; }
            set { _ImgPath = value; }
        }
        public bool IsNews { get; set; }
        public News()
        { }

        public News(int Id, string Title, string Content, Nullable<int> CategoryId, Nullable<int> UserId, Nullable<DateTime> CreatedTime, Nullable<bool> IsActive, Nullable<bool> IsRemove, string ImgPath, string Description,bool IsNews)
        {
            this.Id = Id;
            this.Title = Title;
            this.Content = Content;
            this.CategoryId = CategoryId;
            this.UserId = UserId;
            this.CreatedTime = CreatedTime;
            this.IsActive = IsActive;
            this.IsRemove = IsRemove;
            this.ImgPath = ImgPath;
            this.Description = Description;
            this.IsNews = IsNews;
        }

        public override string ToString()
        {
            return "Id = " + Id.ToString() + ",Title = " + Title + ",Content = " + Content + ",CategoryId = " + CategoryId.ToString() + ",UserId = " + UserId.ToString() + ",CreatedTime = " + CreatedTime.ToString() + ",IsActive = " + IsActive.ToString() + ",IsRemove = " + IsRemove.ToString() + ",ImgPath = " + ImgPath + ",Description=" + Description;
        }

        public class IdComparer : System.Collections.Generic.IComparer<News>
        {
            public SorterMode SorterMode;
            public IdComparer()
            { }
            public IdComparer(SorterMode SorterMode)
            {
                this.SorterMode = SorterMode;
            }
            #region IComparer<News> Membres
            int System.Collections.Generic.IComparer<News>.Compare(News x, News y)
            {
                if (SorterMode == SorterMode.Ascending)
                {
                    return y.Id.CompareTo(x.Id);
                }
                else
                {
                    return x.Id.CompareTo(y.Id);
                }
            }
            #endregion
        }
        public class TitleComparer : System.Collections.Generic.IComparer<News>
        {
            public SorterMode SorterMode;
            public TitleComparer()
            { }
            public TitleComparer(SorterMode SorterMode)
            {
                this.SorterMode = SorterMode;
            }
            #region IComparer<News> Membres
            int System.Collections.Generic.IComparer<News>.Compare(News x, News y)
            {
                if (SorterMode == SorterMode.Ascending)
                {
                    return y.Title.CompareTo(x.Title);
                }
                else
                {
                    return x.Title.CompareTo(y.Title);
                }
            }
            #endregion
        }
        public class ContentComparer : System.Collections.Generic.IComparer<News>
        {
            public SorterMode SorterMode;
            public ContentComparer()
            { }
            public ContentComparer(SorterMode SorterMode)
            {
                this.SorterMode = SorterMode;
            }
            #region IComparer<News> Membres
            int System.Collections.Generic.IComparer<News>.Compare(News x, News y)
            {
                if (SorterMode == SorterMode.Ascending)
                {
                    return y.Content.CompareTo(x.Content);
                }
                else
                {
                    return x.Content.CompareTo(y.Content);
                }
            }
            #endregion
        }
        public class ImgPathComparer : System.Collections.Generic.IComparer<News>
        {
            public SorterMode SorterMode;
            public ImgPathComparer()
            { }
            public ImgPathComparer(SorterMode SorterMode)
            {
                this.SorterMode = SorterMode;
            }
            #region IComparer<News> Membres
            int System.Collections.Generic.IComparer<News>.Compare(News x, News y)
            {
                if (SorterMode == SorterMode.Ascending)
                {
                    return y.ImgPath.CompareTo(x.ImgPath);
                }
                else
                {
                    return x.ImgPath.CompareTo(y.ImgPath);
                }
            }
            #endregion
        }
    }
}
